/**
 * 修改js
 * @returns
 */

layui.use(['jquery','layer','table','form','upload'],function(){
    var $ = layui.$,
        layer = layui.layer,
        form = layui.form,
        upload = layui.upload,
        table = layui.table;
    
    upload.render({
		url : 'http://backend.anjuyi.com.cn/layUpload',//上传接口 
		 elem: '#test8',
		 accept: 'file',
		success : function(res) {
			
			document.getElementById("imgs").src = 'http://static.zgclmlhh.org.cn'
					+ res.data;
			document.getElementById("photos").value = res.data;
		}
	});
    
    
    //页面加载完成
    $(document).ready(function(){ 
    	var id = GetQueryString("id");
    	$.post("/systemsetup/basicsetup/blogroll/getByBlogroll",{id:id},function(result){
    		$("#title").val(result.data["title"]);
    		$("#ID").val(id);
    		$("#url").val(result.data["url"]);
    		$("#picture").val(result.data["picture"]);
    		$("#sort").val(result.data["sort"]);
    	});
    });
    
    
    //监听提交
    form.on('submit(blogrollAdd)', function(data){
    	$.post("/systemsetup/basicsetup/blogroll/updateBlogroll",data.field,function(result){
    		if (result.status == 200) {
    			layer.msg(result.msg);
    			var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
    			parent.layer.close(index); //再执行关闭  
			} else {
				layer.msg(result.msg);
			}
    	});
    	
    	return false;
    });
    
});